package com.shxt.framework.rbac.role.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import com.shxt.framework.rbac.menu.service.MenuService;
import com.shxt.framework.rbac.role.service.RoleService;

@Controller
@RequestMapping("/sys/role")
public class RoleController {
	@Autowired
	private RoleService roleService;
	@Autowired
	private MenuService menuService;

	@GetMapping("/list")
	public String index(Model model) {
		model.addAttribute("roleList", this.roleService.getAllRoleList());
		return "role/list";
	}


	@GetMapping("/update/{role_id}")
	//占位符传递数据，这个注解不可以省略掉
	public String update(@PathVariable Integer role_id, Model model) {
		model.addAttribute("role", this.roleService.load(role_id));
		return "role/update";
	}

	@GetMapping("/add")
	public String add() {
		return "role/add";
	}

	@GetMapping("/user")
	public String user() {
		return "role/user";
	}
}
